package lily.ui.control;



import lily.phs.urh.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;

public class MyPopupWindow extends PopupWindow{
	
	Button bt;
	DateChooseView dcv;
	
	public MyPopupWindow(Context context){
		super(context);
		LayoutInflater mLayoutInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
		View view = mLayoutInflater.inflate(R.layout.popup_window_layout, null);
		Bitmap mFgBitmap=BitmapFactory.decodeResource(context.getResources(),R.drawable.appwidget_bg);
		BitmapDrawable bmd=new BitmapDrawable(mFgBitmap);
		this.setBackgroundDrawable(bmd);
		bt=(Button)view.findViewById(R.id.bt_popupwindow);
		this.setContentView(view);
		dcv=new DateChooseView(context);
		RelativeLayout rl=(RelativeLayout)view.findViewById(R.id.rldcv);
		rl.addView(dcv);
		
		this.setWindowLayoutMode(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		this.setOutsideTouchable(true);
		
		
		this.setAnimationStyle(android.R.style.Animation_Dialog);
		this.update();
		this.setTouchable(true);
		this.setFocusable(true);	
	}
	
	public Button getButton(){
		return bt;
	}
	
	public String getDate(){
		return dcv.dateString();
	}
	
	public int getYear() {
		return dcv.getYear();
	}

	public void setYear(int year) {
		dcv.setYear(year);
	}

	public int getMonth() {
		return dcv.getMonth();
	}

	public void setMonth(int month) {
		dcv.setMonth(month);
	}

	public int getDay() {
		return dcv.getDay();
	}

	public void setDay(int day) {
		dcv.setDay(day);
	}

}
